package info.ask4research.web.dto;

import info.ask4research.model.enums.ServiceType;
import info.ask4research.model.roles.Role;
import info.ask4research.model.toolsAndMaterials.AnnouncementService;
import info.ask4research.model.toolsAndMaterials.ChatService;
import info.ask4research.model.toolsAndMaterials.ForumService;
import info.ask4research.model.toolsAndMaterials.LearningObject;
import info.ask4research.model.toolsAndMaterials.SentMailService;
import info.ask4research.model.toolsAndMaterials.ToolAndMaterial;

import java.util.ArrayList;
import java.util.List;

public class EditToolAndMaterialDTO {

	private String title;
	private String description;
	private String tamInstance;
	private String id;
	private Role manager;
	private Role moderator;
	private ServiceType serviceType;
	private List<Role> participants = new ArrayList<Role>();
	private List<Role> observers = new ArrayList<Role>();

	public EditToolAndMaterialDTO(ToolAndMaterial toolAndMaterial) {
		this.title = toolAndMaterial.getTitle();
		if (toolAndMaterial instanceof LearningObject){

			this.description = toolAndMaterial.getDescription();
			this.tamInstance = "LearningObject";
		}else if(toolAndMaterial instanceof ForumService){
			this.description = toolAndMaterial.getDescription();
			this.manager = ((ForumService) toolAndMaterial).getManager();
			this.moderator = ((ForumService) toolAndMaterial).getModerator();
			this.participants = ((ForumService) toolAndMaterial).getParticipants();
			this.observers = ((ForumService) toolAndMaterial).getObservers();
			this.tamInstance = "ForumService";
			
		}else if(toolAndMaterial instanceof AnnouncementService){
			this.description = toolAndMaterial.getDescription();
			this.manager = ((AnnouncementService) toolAndMaterial).getManager();
			this.moderator = ((AnnouncementService) toolAndMaterial).getModerator();
			this.participants = ((AnnouncementService) toolAndMaterial).getParticipants();
			this.observers = ((AnnouncementService) toolAndMaterial).getObservers();
			this.tamInstance = "AnnouncementService";
			
		}else if(toolAndMaterial instanceof ChatService){
			this.description = toolAndMaterial.getDescription();
			this.manager = ((ChatService) toolAndMaterial).getManager();
			this.moderator = ((ChatService) toolAndMaterial).getModerator();
			this.participants = ((ChatService) toolAndMaterial).getParticipants();
			this.observers = ((ChatService) toolAndMaterial).getObservers();
			this.tamInstance = "ChatService";
			
		}else if(toolAndMaterial instanceof SentMailService){
			this.description = toolAndMaterial.getDescription();
			this.participants = ((SentMailService) toolAndMaterial).getRecipients();
			this.serviceType = ((SentMailService) toolAndMaterial).getServiceType();
			this.tamInstance = "SentMailService";
			
		}

	}


	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}


	public String getDescription() {
		return description;
	}


	public void setDescription(String description) {
		this.description = description;
	}


	public String getTamInstance() {
		return tamInstance;
	}


	public void setTamInstance(String tamInstance) {
		this.tamInstance = tamInstance;
	}


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public Role getManager() {
		return manager;
	}


	public void setManager(Role manager) {
		this.manager = manager;
	}


	public Role getModerator() {
		return moderator;
	}


	public void setModerator(Role moderator) {
		this.moderator = moderator;
	}


	public List<Role> getParticipants() {
		return participants;
	}


	public void setParticipants(List<Role> participants) {
		this.participants = participants;
	}


	public List<Role> getObservers() {
		return observers;
	}


	public void setObservers(List<Role> observers) {
		this.observers = observers;
	}


	public ServiceType getServiceType() {
		return serviceType;
	}


	public void setServiceType(ServiceType serviceType) {
		this.serviceType = serviceType;
	}



}
